﻿using System;
using System.Globalization;
using System.Windows.Data;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;
using StockholmsStad.Utilities;

namespace StockholmsStad.Windows.UI.Infrastructure.Converters
{
    public class UserRoleToStringConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            if (value is UserRole)
            {
                var role = (UserRole)value;
                return EnumUtility.GetEnumDescription(role);
            }
            
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return string.Empty;

            return value as string;
        }

        #endregion
    }

}
